package com.topnav.mc.admin.entity;

import java.io.Serializable;
import java.util.*;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import com.baomidou.mybatisplus.annotation.TableName;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.SpringSecurityCoreVersion;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.util.Assert;
import com.baomidou.mybatisplus.annotation.TableField;
import com.topnav.mc.entity.base.BaseEntity;
import com.topnav.mc.validator.group.IAdd;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
 * 说明：用户实体类
 * @类名: User
 * <p>
 *  集成spring security 所以实现 UserDetails接口
 * </p>
 * @author   kenny
 * @Date	 2021年11月16日下午4:20:44
 */
//@Entity
@TableName("mc_user")
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class User extends BaseEntity {

	/** */
	private static final long serialVersionUID = -1633810897974854392L;

	@NotBlank(message = "不允许为空",groups={IAdd.class})
	private String loginName;
	//@NotBlank(message = "不允许为空",groups={IAdd.class})
	private String password;

	@NotBlank(message = "不允许为空",groups={IAdd.class})
	private String code;
	@NotBlank(message = "不允许为空",groups={IAdd.class})
	private String name;

	/** 所属单位, 不会随着登录的变化而变化 */
	private Long orgId;

	/** 登录单位，登录的时候是哪个机构的权限，默认是所属单位*/
	private Long loginOrgId;

	/** 1 正式员工 2临时人员 */
    @Min(value=1,message = "必须1-2",groups={IAdd.class})
    @Max(value=2,message = "必须1-2",groups={IAdd.class})
    @NotNull(message = "不允许为空",groups={IAdd.class})
	private Integer type;

	/** 启用/禁用 */
    private Boolean enabled;
	/** 启用/禁用 */
	private Boolean enabledNotify;

//	private Date validTime;

	/** 一个用户属于多个单位 */
/*
	@TableField(exist=false)
	private List<UserOrganizaiton> UserOrganizaitons;
*/

	@TableField(exist=false)
	private List<Role> roles;

/*	public Boolean getEnabled(){
		return this.enabled;
	}*/

/*	@TableField(exist=false)
	private Set<GrantedAuthority> authorities;*/

}
